﻿using System;
using System . Collections . Generic;
using System . Linq;
using System . Text;
using System . IO;
using System . Threading . Tasks;
using System . Xml . Linq;
using System . Xml;
using System . Reflection;
using GameClassLibrary . Players;

namespace GameClassLibrary . Players . Models
{
    public class PlayerModelProxy
    {

        public string FileName { get; set; }

        public string Name { get; set; }

        public string Introduction { get; set; }

        public Uri Image { get; set; }

        public static List<PlayerModelProxy> playerModel=null;

        public static List<PlayerModelProxy> GetPlayerModel ( )
        {
            if ( null == playerModel )
            {
                XDocument Doc= ResourceHelper.GetXmlDocument(@"PlayerModel.Index.xml");

                var a=from p in Doc.Descendants()
                      select new PlayerModelProxy
                      {
                          Name=( string )p.Attribute("Name"),
                          FileName=(string )p.Attribute("FileName"),
                          Image=new Uri( ( string ) p.Attribute("Image"))
                      };

                List<PlayerModelProxy> temp=new List<PlayerModelProxy>();

                temp . AddRange ( a );

                playerModel = temp;

                return temp;
            }
            else
            {
                return playerModel;
            }

        }

    }
}


